{include file="public/header" /}
<title>{:lang('我要投资')}</title>
<header id="header" class="mui-bar mui-bar-nav">
    <div class="mui-pull-left PopupNavigation">
        <img src="/static/home/bl_1.png" alt="">
    </div>
    <h1 class="mui-title">{:lang('我要投资')}</h1>
    <div class="mui-pull-right" style="display: none;">
        <div class="mui-switch mui-active">
            <div class="mui-switch-handle"></div>
        </div>
    </div>
</header>    

{include file="public/menu" /}

<div id="pullrefresh" class="mui-content">
    <div class="mui-scroll">
        <div class="iwanvestBox">
            <div class="iwanvesttl" style="margin-bottom: 10px;">
                <span class="span_1">{:lang('总投资')}</span>
                <span class="span_2">${:number_format($user['invest'],2)}</span>
                <span class="span_1">&nbsp;{:lang('筹码')}</span>
                <span class="span_2">${:number_format($user['chip'],2)}</span>
                <span class="span_1">&nbsp;{:lang('积分')}</span>
                <span class="span_2">${:number_format($user['money'],2)}</span> <br />
                <span class="span_1">{:lang('冻结积分')}</span>
                <span class="span_2">${:number_format($user['integral_frozen'],2)}</span>
            </div>

            <input type="number" name="integral" id="integral" autocomplete="off" class="gisteinput" placeholder="{:lang('请输入整数积分数量')}">

            {foreach :config('base.invest') as $k=>$v}
            <div class="iwanvestCont df">
                    <div class="iwanvestConttl">{:lang('投资金额')}</div>
                    <div class="fx1">
                        <div class="df">
                            <div class="fx1 iwanvestContsz">${$v}</div>
                            <button class="iwanvestContan investSub" data-id="{$k}" type="button">{:lang('投资')}</button>
                        </div>
                    </div>
                </div>
            {/foreach}

        </div>

        <div class="staataBox">
            <div class="staataTl">{:lang('个人投资历史记录')}</div>
            <div class="staataTableBox">
                <table class="tabletada" border="0" cellspacing="" cellpadding="">
                    <thead>
                        <tr>
                            <th>{:lang('投资时间')}</th>
                            <th>{:lang('投资金额')}</th>
                        </tr>
                    </thead>
                    <tbody id="content"><tr>
 
                    </tbody>
                </table>
            </div>
        </div>

    </div>
{include file="public/footer" /}
<script src="/static/home/echarts.min.js" type="text/javascript" charset="utf-8"></script>
<script>
    mui('.mui-scroll-wrapper').scroll({
        deceleration: 0.0005
    });
    mui('body').on('tap', ".investSub", function () {
        var btnArray = ["{:lang('确认')}", '取消'];
        var _this = $(this);
        var integral = $("#integral").val();
        mui.confirm('{:lang('您确定要投资入金该套餐')}！', '投资', btnArray, function (e) {
            if(e.index == 0) {
                $.post("{:url('Invest/investment')}", {id: _this.data('id'),integral:integral}, function (res) {
                    console.log(res);
                    if (res.status == 1) {
                        mui.toast(res.msg);
                        window.location.reload();
                    } else {
                        mui.alert(res.msg);
                    }
                });
            }
        });
    });
    var stop = true;
    function ajax_get_invest_log() {
        if (stop == true) {
            $('#investLogContent').html('');
            stop = false;
            $.ajax({
                type: "POST",
                url: "{:url('Invest/investLog')}",
                success: function(data) {
                    mui.hideLoading();
                    if (data.status == 0) {
                        mui.toast(data.msg, {
                            duration: 'long',
                            type: 'div'
                        });
                        return;
                    }
                    $('.loadAdd').hide();
                    // layer.close(getMoreLoad);
                    if ($.trim(data) == '') {
                        stop=false;
                    } else {
                        stop = true;
                        let html = '';
                        for(var i = 0;i<data.list.length;i++){
                            html += '<tr><td>'+data.list[i].created+'</td>';
                            html += '<td>'+data.list[i].chip+'</td>';
                            html += '</tr>';
                        }
                        $('#content').append(html);
                    }
                },error:function(){
                    mui.toast('网络失败，请刷新后重试',{ duration:'long', type:'div' })
                }
            });
        }
    }

    var bottomH = 50;//距离底部多少像素开始加载
    var stop = true;
    $(window).scroll(function () {
        totalheight = parseFloat($(window).height()) + parseFloat($(window).scrollTop() + bottomH);
        if ($(document).height() <= totalheight) {
            ajaxGetOrder();
        }
    });
    ajax_get_invest_log();
</script>


</body></html>